<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <script type="text/javascript" src="js/libs/autocomplete.js"></script>
        <script type="text/javascript" src="js/libs/jquery-1.3.2.min.js"></script>
        <link rel="stylesheet" type="text/css" href="css/newPark.css">
        <link rel="stylesheet" type="text/css" href="css/default.css">
        <link rel="stylesheet" type="text/css" href="css/menu.css">
        <link rel="stylesheet" type="text/css" href="css/autocomplete.css">

        <script type="text/javascript">
            $(document).ready(function(){
                new Autocomplete("parkCli", function() {
                    this.setValue = function(cpf,idcli) {
                        $("#parkCpfResInput").val(cpf);
                        $("#parkCliId").val(idcli); 
                    }
                    if ( this.isModified ){
                        this.setValue("");
                    }
                    if ( this.value.length < 1 && this.isNotClick ){
                        return ;
                    }
                    return "autoCompleteCli.php?q=" + this.value;
                });

            });
        </script>

        <script type="text/javascript">
            $(document).ready(function(){
                new Autocomplete("parkCar", function() {
                    this.setValue = function(model,color,year,idcar) {
                        $("#parkModelInput").val(model);
                        $("#parkColorInput").val(color);
                        $("#parkYearInput").val(year);
                        $("#parkCarId").val(idcar);
                    }
                    if ( this.isModified ){
                        this.setValue("");
                    }
                    if ( this.value.length < 1 && this.isNotClick ){
                        return ;
                    }
                    return "autoCompleteCar.php?q=" + this.value;
                });

            });
        </script>
    </head>
    <body>
        <div id="container">

           <div id="title">
                <div id="img">
                <img src="css/ico_car.png"/>
                </div>
                <div id="h1">
                <h1>Park Control</h1>
                </div>
            </div>
            <div id="menu">
                <ul class="menu">
                    <li><a href="#" title="Cadastros">Cadastros</a>
                        <ul>
                            <li><a href="newCli.php" target="_parent" >Cadastrar Clientes</a></li>
                            <li><a href="newCar.php" target="_parent">Cadastrar Carros</a></li>
                            <li><a href="newFares.php" target="_parent">Cadastrar Tarifas</a></li>
                        </ul>
                    </li>
                    <li><a href="#" title="Gerenciar">Gerenciar</a>
                        <ul>
                            <li><a href="newPark.php" target="_parent">Entrada de Carros</a></li>
                            <li><a href="relExitPark.php" target="_parent">Saida de Carros</a></li>
                        </ul>
                    </li>
                    <li><a href="#" title="Relatorios">Relatorios</a>
                        <ul>
                            <li><a href="relCar.php" target="_parent">Relatório de Carros</a></li>
                            <li><a href="relCli.php" target="_parent">Relatório de Clients</a></li>
                            <li><a href="relPark.php" target="_parent">Relatório de Entradas</a></li>    
                        </ul>
                    </li>
                </ul>
            </div>

            <form method="POST" action="action/InsertEntries.action.php" name="newParkForm" id="newParkForm">
                <?php include 'action/SerarchFares.action.php'; ?>
                <div id="span"> 
                    <span id="newCliError" class="error"><h2>Entrada de Carros</h2></span>
                </div>
                <div id="newParkDiv">
                    <fieldset>
                        <span id="newParkError" class="error"></span>
                        <input type="hidden" id="parkCliId" name="idcli" value=""/>
                        <input type="hidden" id="parkCarId" name="idcar" value=""/>

                        <label id="newParkCliLabel">
                            Cliente:
                            <input type="text" id="parkCliInput" name="parkCli" value="" size=40 maxlength=40>
                        </label> 

                        <label id="newParkCpfLabel">
                            CPF:
                            <input type="text" id="parkCpfResInput" name="cpf" value="" readonly="true" size=11 maxlength=11 >
                        </label>

                        <label id="newParkCarLabel">
                            Placa do Carro:
                            <input type="text" id="parkCarInput" name="parkCar" value="" size=8 maxlength=8>
                        </label> 

                        <label id="newParkModelLabel">
                            Modelo:
                            <input type="text" id="parkModelInput" name="model" value="" readonly="true" >
                        </label>

                        <label id="newParkColorLabel">
                            Cor:
                            <input type="text" id="parkColorInput" name="color" value="" readonly="true" size=10 maxlength=10>
                        </label>

                        <label id="newParkYearLabel">
                            Ano:
                            <input type="text" id="parkYearInput" name="year" value="" readonly="true" size=4 maxlength=4>
                        </label>
                        <label id="newParkDateIn">
                            Data Entrada:
                            <input type="text" id="newParkDateIn" name="newParkDateIn" value="<?php
                ini_set('date.timezone', 'America/SAO_PAULO');
                echo date('d/m/y H:i:s')
                ?>"   >
                        </label>
                        <label id="newParkDateIn">
                            Data Saída:
                            <input type="text" id="newParkDateout" name="newParkDateout" value="<?php
                                   ini_set('date.timezone', 'America/SAO_PAULO');
                                   echo date('d/m/y H:i:s')
                ?>"   >
                        </label>

                        <label id="cliTaxLabel">
                            Tarifa:
                            <select name="fares"  value="" onChange="javascript:this.value=this.value.toUpperCase();">
                                <?php
                                if ($fares) {
                                    foreach ($fares as $f) {
                                        $value = $f->getFares();?>

                            <option value="<?php echo $f->getFares() ?> ">  
                                <?php
                                    echo "R$ " . number_format($value, 2, ',', '.');
                                    echo" - " . $f->getDescription();
                                        ?>  </option> <?php
                                    }
                                }
                                ?>  
                            </select>
                        </label>
                </div>    
                <div id="buttons">
                    <input type="submit" id="cliOkButton" value = "Cadastrar" />
                    <input type="reset" id="cliResetButton" value = "Limpar" />
                </div>

        </div>
    </form>
</div>   

</body>
</html>